
// 获取全局应用程序实例对象
const app = getApp()
Page({
  data: {
    header: [{ "img": "/../image/1.jpg", "company": "京科卓佳科技有限公司", "job": "董事长", "name": "陈忠义" }],
    lianxi: [{ "QICQ": "1234564648", "weixin": "124548", "phone": "146516", "Email": "4648498@qq.com", "image": "/../image/2.jpg" }],
    listData: [
      { "name": "电话", "phone": "1500000000", "text": "拨打" },
      { "name": "微信", "phone": "1500000000", "text": "复制" },
      { "name": "邮箱", "phone": "1500000000@qq.com", "text": "复制" },
      { "name": "公司", "phone": "深圳京科卓佳科技有限公司" },
      { "name": "地址", "phone": "广东省深圳市福田区车公庙喜年中心26栋1819" }
    ],
    cardInfo: '',
    image: app.globalData.apiUrl + '/public/uploads/logo/head.jpg',
    restaurant: {
      // img: '/images/honglanliang.jpg',
      name: '京科卓佳科技有限公司',
    },
    phone: [{ "phone": "13798419663", "tel": "0755-33228631" }],
    latitude: 22.5346800000,
    longitude: 114.0238900000,
    markers: [{
      id: 1,
      latitude: 22.5346800000,
      longitude: 114.0238900000,
      name: '深圳市福田区车公庙喜年中心26栋1819'
    }],
    covers: [{
      latitude: 22.5346800000,
      longitude: 114.0238900000,
    }, {
      latitude: 22.5346800000,
      longitude: 114.0238900000,
    }],
    cardInfo:'',
  },
  click: function (e) {
    wx.openLocation({
      latitude: 22.5346800000,
      longitude: 114.0238900000,
      scale: 18,
      name: '京科卓佳科技有限公司',
      address: '深圳市福田区车公庙喜年中心26栋1819'
    })
  },
  onPullDownRefresh: function onPullDownRefresh() {
    // TODO: onPullDownRefresh
  },
  onShareAppMessage: function () {
    return {
      title: '',
      path: ''
    }
  },
  onLoad:function(){
    var _this = this;
    wx.request({
      url: app.globalData.apiUrl + '/api/card/cardInfo',
      method: 'GET',
      dataType: 'json',
      success: function (res) {
        console.log(res);
        _this.setData({ cardInfo: res.data })
      },
      fail: function (res) { },
      complete: function (res) { },
    })
    var _this = this;
    wx.request({
      url: app.globalData.apiUrl+'/api/card/cardInfo',
      method: 'GET',
      dataType: 'json',
      success: function(res) {
        _this.setData({cardInfo:res.data})
      },
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  call:function(tab){
    console.log(tab.currentTarget.id)
    if (tab.currentTarget.id==1){
    wx.makePhoneCall({
      phoneNumber: this.data.cardInfo.phone //仅为示例，并非真实的电话号码
    })

  }else{
      wx.makePhoneCall({
        phoneNumber: this.data.cardInfo.telephone //仅为示例，并非真实的电话号码
      })
   }
  },
  baocun: function () {
    wx.addPhoneContact({
      lastName: "陈",
      firstName: "忠义",
      organization: this.data.cardInfo.company,
      mobilePhoneNumber: this.data.cardInfo.phone
    })
  },
  jkjs: function () {
    wx.setClipboardData({
      data: '1500000000',
      success: function (res) {
        wx.getClipboardData({
          success: function (res) {
            console.log(res.data) // data
          }
        })
      }
    })
  },
  // 打电话
  call: function () {
    wx.makePhoneCall({
      phoneNumber: this.data.cardInfo.phone //仅为示例，并非真实的电话号码
    })
  },
  // 复制
  copy: function () {
    wx.setClipboardData({
      data: this.data.cardInfo.weixin,
      success: function (res) {
        wx.getClipboardData({
          success: function (res) {
            console.log(res.data) // data
          }
        })
      }
    })
  },
  copyEmail: function () {
    wx.setClipboardData({
      data: this.data.cardInfo.email,
      success: function (res) {
        wx.getClipboardData({
          success: function (res) {
            console.log(res.data) // data
          }
        })
      }
    })
  },
  onShareAppMessage: function (e) {
    if (e.from === 'button') {
      console.log(e.target)
    }
  },
});

